package com.freemyleft.left.zapp.selectimage;

import android.app.Activity;
import android.util.Log;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

import java.io.File;

/**
 * Created by Administrator on 2017/6/7.
 */

public class PicassoUtils {
    public static void picasso(Activity activity, String path, int width, int height, ImageView imageView){
            picasso(activity,path,width,height,imageView, false);
    }
    public static void picasso(Activity activity, String path, int width, int height, ImageView imageView, boolean isZoom){
        Log.e("picasso--->原图：", "width="+ width + ",,height="+ height);
        if (width == 0)
            width = 300;
        if (height == 0){
            height =300;
        }
        if (isZoom && height > 1080*2){
            height= height/2;
            width = width /2;
            Log.e("picasso--->压缩：", "width="+ width + ",,height="+ height);
        }
        Picasso.with(activity)
                .load(new File(path))
                .resize(width, height)
                .centerCrop()
                .into(imageView);
    }
}
